/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
var ShowMap = [];
//初始化地图
ShowMap.init = function () {
    ShowMap.ShowMap = echarts.init(document.getElementById('map'));
    ShowMap.ShowMap.setOption(ShowMap.option);
};
ShowMap.server_list = [];
ShowMap.ShowMap = {};// 地图对象
ShowMap.option = {// 地图展示参数
    tooltip: {
        trigger: 'item',
        formatter: '{b}'
    },
    color: GetData.color,
    series: [
        {
            name: '',
            type: 'map',
            roam: false,
            hoverable: false,
            mapType: 'world',
            itemStyle: {
                normal: {
                    borderColor: '#777',
                    borderWidth: 0.5,
                    areaStyle: {
                        color: '#1b1b1b'
                    }
                }
            },
            data: []
        }
    ]
};
// 给一个服务器节点分配一个地图展示层
ShowMap.GetNodeID = function (node) {
    var node_id = 0;
    if (undefined === ShowMap.server_list[node]) {
        node_id = ShowMap.server_list[node] = ShowMap.server_list.length;
        ShowMap.server_list.length++;
    } else {
        node_id = ShowMap.server_list[node];
    }
    return node_id;
};
// 在服务器节点和客户端之间划线
ShowMap.ShowNode = function (node, client) {
    var node_data = [];
    for (key in client) {
        node_data.push([client[key], GetData.server_list[node].geo]);
        
    }
    
    ShowMap.option.series[ShowMap.GetNodeID(node)] = {
        name: GetData.server_list[node].name,
        type: 'map',
        mapType: 'world',
        data: [],
        markLine: {
            smooth: true,
            effect: {
                show: true,
                scaleSize: 1,
                period: 30,
                color: GetData.server_color[node],
                shadowBlur: 10
            },
            itemStyle: {
                normal: {
                    borderWidth: 0.2,
                    lineStyle: {
                        type: 'solid',
                        color: GetData.server_color[node],
                        shadowBlur: 10
                    }
                }
            },
            data: node_data
        }
    };
    ShowMap.ShowMap.setOption(ShowMap.option);
};

